package com.yixun.qfbao.response.login;
/**
 * @author zilong.liu
 * @date 2020-12-1
 *
 * desc:
 *     
 */

import java.util.ArrayList;
import java.util.List;

import org.springframework.util.CollectionUtils;

import com.yixun.qfbao.model.Area;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class AreaResponse {
	
	@ApiModelProperty(value = "id")
	private Long id;
	
	@ApiModelProperty(value = "地区名称")
	private String areaName;
	
	/**
	 * area 集合 转换成当前类集合
	 * @param areaList
	 * @return
	 */
	public static List<AreaResponse> listConvertAreaToAreaResponse(List<Area> areaList) {
		if(CollectionUtils.isEmpty(areaList)) {
			return null;
		}
		List<AreaResponse> areaResponseList = new ArrayList<>(areaList.size());
		for (Area area : areaList) {
			areaResponseList.add(convertAreaToAreaResponse(area));
		}
		return areaResponseList;
	}
	
	/**
	 * area 转换成当前类
	 * @param area
	 * @return
	 */
	public static AreaResponse convertAreaToAreaResponse(Area area) {
		AreaResponse areaResponse = new AreaResponse();
		areaResponse.setId(area.getId());
		areaResponse.setAreaName(area.getName());
		return areaResponse;
	}
}
